from django.urls import re_path
from rest_framework.routers import DefaultRouter
from apps.work.views import WorkModelViewSet
from apps.work.views import KqOrdersModelViewSet
from apps.work.views import KqExtendInfoModelViewSet
from apps.work.views import KqMaintainModelViewSet
from apps.work.views import KqPriceInfoModelViewSet
from apps.work.views import KqPumpsModelViewSet
from apps.work.views import KqAllProjectsModelViewSet
from apps.work.views import WorkDeptModelViewSet
from apps.work.views import WorkRoleModelViewSet
from apps.work.views import WorkUserModelViewSet
router = DefaultRouter()
router.register(r'kqAllInfo', WorkModelViewSet)
router.register(r'allOrders', KqOrdersModelViewSet)
router.register(r'kqExtendInfo', KqExtendInfoModelViewSet)
router.register(r'kqMaintainInfo', KqMaintainModelViewSet)
router.register(r'kqPriceInfo', KqPriceInfoModelViewSet)
router.register(r'KqPumpsInfo', KqPumpsModelViewSet)
router.register(r'project', KqAllProjectsModelViewSet)
router.register(r'dept', WorkDeptModelViewSet)
router.register(r'dept/exclude', WorkDeptModelViewSet)
router.register(r'role', WorkRoleModelViewSet)
router.register(r'user', WorkUserModelViewSet)

urlpatterns = [

    # ----- 客户中心------------
    # 导出项目
    re_path('kqAllInfo/export/', WorkModelViewSet.as_view({'get': 'export', })),
    re_path('kqExtendInfo/getExtendInfoByCompId/(?P<pk>.*)/', KqExtendInfoModelViewSet.as_view({'get': 'get_extend_info_by_id'})),
    # 导出角色
    # re_path('role/export/', WorkRoleModelViewSet.as_view({'get': 'export', })),

    # 项目导入模板下载及导入
    re_path('kqAllInfo/importTemplate/',
            WorkModelViewSet.as_view({'get': 'importTemplate', 'post': 'importTemplate'})),
    re_path('kqAllInfo/updateKqInfoStatus/', WorkModelViewSet.as_view({'put': 'update_kq_info_status'})),
    re_path('kqAllInfo/batchUpdateKqInfo/', WorkModelViewSet.as_view({'post': 'batch_update_kq_info_status'})),
    # 批量更新删除状态
    re_path('kqAllInfo/batchDeleteKqInfo/', WorkModelViewSet.as_view({'post': 'batch_delete_kq_info'})),
    # recoverKqInfo 解除一条删除数据
    re_path('kqAllInfo/recoverKqInfo/', WorkModelViewSet.as_view({'post': 'recover_kq_info'})),

    # ----- 订单中心------------
    # 导出项目
    re_path('allOrders/export/', KqOrdersModelViewSet.as_view({'get': 'export', })),
    # 项目导入模板下载及导入
    re_path('allOrders/importTemplate/',
            KqOrdersModelViewSet.as_view({'get': 'importTemplate', 'post': 'importTemplate'})),
    # ----- 订单中心------------
    # 导出项目
    re_path('kqMaintainInfo/export/', KqMaintainModelViewSet.as_view({'get': 'export', })),
    re_path('KqPumpsInfo/export/', KqPumpsModelViewSet.as_view({'get': 'export', })),
    re_path('dept/exclude/(?P<pk>.*)/', WorkDeptModelViewSet.as_view({'get': 'exclude_list'})),
    re_path('dept/treeselect/', WorkDeptModelViewSet.as_view({'get': 'tree_select_list'})),
    # 根据角色ID查询部门树结构
    re_path('dept/roleDeptTreeselect/(?P<pk>.*)/', WorkDeptModelViewSet.as_view({'get': 'role_dept_tree_select'})),

    # 更新状态
    re_path('user/changeStatus/', WorkUserModelViewSet.as_view({'put': 'change_status'})),
    # 获取用户详情
    re_path('user/details/', WorkUserModelViewSet.as_view({'get': 'get_user_details'})),
    # 后台重置密码
    re_path('user/resetPwd/', WorkUserModelViewSet.as_view({'put': 'reset_pwd'})),
    # 用户自己重置密码
    re_path('user/profile/updatePwd/', WorkUserModelViewSet.as_view({'put': 'update_pwd'})),
    # 更新用户头像
    re_path('user/profile/avatar/', WorkUserModelViewSet.as_view({'put': 'put_avatar'})),
    # 获取、更新用户个人信息
    re_path('user/profile/', WorkUserModelViewSet.as_view({'get': 'profile', 'put': 'put_profile'})),
    # 导出用户
    re_path('user/export/', WorkUserModelViewSet.as_view({'get': 'export', })),

]

urlpatterns += router.urls
